<template>
  <div class="app-container">
    <el-row :gutter="20">
      <el-col :span="6" :xs="24">
        <el-card class="box-card">
          <div slot="header" class="clearfix">
            <span>个人信息</span>
          </div>
          <div>
            <div class="text-center">
              <userAvatar :userInfo="userInfo" />
            </div>
            <ul class="list-group list-group-striped">

              <li class="list-group-item">
                <svg-icon icon-class="tree" />所属租户
                <div class="pull-right">{{ userInfo.tenantAbbreviation }}</div>
              </li>

              <li class="list-group-item">
                <svg-icon icon-class="tree-table" />用户类型
                <div class="pull-right">{{ userInfo.userTypeName }}</div>
              </li>

              <li class="list-group-item">
                <svg-icon icon-class="user" />用户姓名
                <div class="pull-right">{{ userInfo.realName }}</div>
              </li>
              <li class="list-group-item">
                <svg-icon icon-class="phone" />手机号码
                <div class="pull-right">{{ userInfo.mobileNumber }}</div>
              </li>
              <li class="list-group-item" v-if="userInfo.roleName">
                <svg-icon icon-class="peoples" />所属角色
                <div class="pull-right">{{ userInfo.roleName }}</div>
              </li>
              <li class="list-group-item">
                <svg-icon icon-class="date" />创建日期
                <div class="pull-right">{{ userInfo.createTime }}</div>
              </li>
            </ul>
          </div>
        </el-card>
      </el-col>
      <el-col :span="18" :xs="24">
        <el-card>
          <div slot="header" class="clearfix">
            <span>基本资料</span>
          </div>
          <el-tabs v-model="activeTab">
            <el-tab-pane label="基本资料" name="userInfo">
              <userInfo :userInfo="userInfo" />
            </el-tab-pane>
            <el-tab-pane label="修改密码" name="resetPwd">
              <resetPwd :userInfo="userInfo" />
            </el-tab-pane>
          </el-tabs>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import userAvatar from "./userHeadPortrait";
import userInfo from "./updateUserInfo";
import resetPwd from "./resetPassword";
import { queryCurrentLoginUserInfoRes } from "@/api/common/currentLoginUser";
export default {
  name: "Profile",
  components: { userAvatar, userInfo, resetPwd },
  data() {
    return {
      userInfo: {},
      activeTab: "userInfo"
    };
  },
  created() {
    this.queryUserInfoRes();
  },
  methods: {
    //查询用户信息
    queryUserInfoRes() {
      queryCurrentLoginUserInfoRes().then(res => {
        this.userInfo = res.data;
      });
    }
  }
};
</script>
